﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FTradeReceivablesYuanJianList.aspx.cs" Inherits="IHISCETeim.Web.MachineSys.FTradeModel.FTradeReceivablesYuanJianList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../EasyUI/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="../EasyUI/themes/icon.css" />
	<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>   
	<script type="text/javascript" src="../EasyUI/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="../EasyUI/easyui-formatter_20140718.js"></script>
     <link href="../themes/css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
    <script src="../js/DWZ/jquery.autocomplete.js" type="text/javascript"></script>
    <script type="text/javascript">
        var YuanJianLists = [
		    {name:'收到'},
		    {name:'未收到'}            
        ];
        function YuanJianListsFormatter(value){
            for(var i=0; i<YuanJianLists.length; i++){
                if (YuanJianLists[i].name == value) return products[i].name;
            }
            return value;
        }

        ///自适应宽高
        $(window).resize(function(){		    
            $("#tab_list").datagrid({
                width: '100%',
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
            }); 
        });

        $(document).ready(function () {
            //权限处理
            var $powers={
                "r查看":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.查看) %>,
                "r导出":<%=HasPowerEasyUI(IHISCETeim.Web.Permission.导出) %> 
                };
            var $tab_toolbar=$("#tab_toolbar");
            $tab_toolbar.find("a").each(function(){
                var $per=$(this).attr("Permission");
                var pt= $powers[$per]==undefined || null?true:$powers[$per];
                $(this).linkbutton(pt?'enable': 'disable');
            })

            //自动完成
            $(".autocomplete").each(function () {
                var $this = $(this);
                var url = unescape($this.attr("autocompletehref"));
                $this.autocomplete(url);
            });
            //条件查询
            $("#search-buttons").find("#btn_search").click(function () {
                var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
                query.action = "query";
                $('#tab_list').datagrid("options").queryParams = query;
                $('#tab_list').datagrid('load');
                $("#tab_search").dialog("close");
                return false;
            });

            var lastIndex;
            $('#tab_list').datagrid({               
                url: location.href,
                queryParams: { "action": "query" },
                sortName: 'FTradeID', //排序字段
                sortOrder: 'desc', //排序类型
                idField: 'JingXiaoShang', //标识字段,主键
                width: '100%', //宽度    
                height: $(parent.document).find(".tabsPageContent").height() - 11 > 0 ? $(parent.document).find(".tabsPageContent").height() - 11 : 500,
                toolbar: "#tab_toolbar",
                //rowStyler:function(index,row)
                //{
                //    if(row.Status=="已发")
                //        return  "color:red;";  
                //},
                onClickRow: function (rowIndex) {
                    //return false;
                    if(<%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>==false || <%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>==undefined )
                    {
                        return false;
                    }
                    if (lastIndex != rowIndex) {
                        $('#tab_list').datagrid('endEdit', lastIndex);
		               
                        $('#tab_list').datagrid('beginEdit', rowIndex);
                    }
                    lastIndex = rowIndex;
                },
                onAfterEdit: function (rowIndex, rowData, changes) {
                    if(<%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>==false || <%=HasPowerEasyUI(IHISCETeim.Web.Permission.修改) %>==undefined )
                    {
                        return false;
                    }
                    var $data={};
                    $data["FTradeID"]=rowData.FTradeID; 
                    //if(changes.HeTongYuanJian==undefined || changes.HeTongYuanJianDate==undefined || changes.ShouHouYuanJian==undefined || changes.ShouHouYuanJianDate==undefined)
                    //    return;
                    //  alert(1);
                    if(changes.HeTongYuanJian==undefined)
                        $data["HeTongYuanJian"]=rowData.HeTongYuanJian;
                    else
                        $data["HeTongYuanJian"]=changes.HeTongYuanJian;

                    if(changes.HeTongYuanJianDate==undefined)
                        $data["HeTongYuanJianDate"]=rowData.HeTongYuanJianDate;
                    else
                        $data["HeTongYuanJianDate"]=changes.HeTongYuanJianDate;

                    if(changes.ShouHouYuanJian==undefined)
                        $data["ShouHouYuanJian"]=rowData.ShouHouYuanJian;
                    else
                        $data["ShouHouYuanJian"]=changes.ShouHouYuanJian;

                    if(changes.ShouHouYuanJianDate==undefined)
                        $data["ShouHouYuanJianDate"]=rowData.ShouHouYuanJianDate;
                    else
                        $data["ShouHouYuanJianDate"]=changes.ShouHouYuanJianDate;
                    
                   
                    $data["action"]="editrow";             
                    $.ajax({
                        type: 'post',
                        url: location.href,
                        data:$data,
                        async: true,
                        cache: false,
                        dataType: "text",
                        success: function (json) {
                            try {
                                if (json!="") {
                                    alert(json);
                                }
                            }
                            catch (e) {

                            }
                        }
                    });
                }
            });   
        })

        //导出管控表
        function onExportList() {
            var href = "<%= ExportExcelWebUrl%>/FTradeModel/FTradeReceivaYuanJian.aspx?" + jQuery.param(getQuery());
            top.window.open(href, "");
            return false;
        }
        function getQuery()
        {
            var query = $("#tab_search").serializeJSON(); // GetInputData("tab_search", "query");
            //处理多值情况
            var xxx = ""
            $("#tab_search").find("input[name='XiaoShouLeiXing']").each(function () {
                xxx += "" + $(this).val() + ","
            });
            query.XiaoShouLeiXing = xxx;
            xxx = ""
            $("#tab_search").find("input[name='FanHuanLiXiState']").each(function () {
                xxx += "" + $(this).val() + ","
            });
            query.FanHuanLiXiState = xxx;

            query.action = "query";
            return query;
        }
    </script>
     
</head>
<body style="margin:2px;" >
     <div id="tab_search" title="查询条件" style=" height:250px; width:500px;" class="easyui-dialog" modal="true" closed="true" buttons="#search-buttons">
         <table class="table_search" width="100%" style=" line-height:21px;">
            <tr>
                <td>经销商:</td>
                <td ><input  name="JingXiaoShang"  class="autocomplete" autocompletehref="<%=AutoCompleteRequestUrl %>?ajaxmethod=getagentlist" mustMatch="true" swidth="300" showinputid=""/></td>
                <td>合同号:</td>
                <td Colspan="3"><input  name="HeTongHao" value="" /></td>
            </tr>
            <tr>
                <td>机型:</td>
                <td ><input  name="XingHao" value="" /></td>
                <td></td>
                <td Colspan="3"></td>
            </tr>
            <tr>
                 <td>机号:</td>
                <td><input  name="JiHao" value="" /></td>
                <td>机器状态:</td>
                <td>
                    <select name="JiQiState">
                        <option value="-" selected>所有...</option>
                        <option value="正常" >一般销售</option>
                        <option value="改分期">改分期</option>
                        <option value="改经销商">改经销商</option>
                        <option value="换机">换机</option>
                        <option value="退机">退机</option>
                    </select>
                </td>
            </tr>
            
            <tr>
                <td>终端客户:</td>
                <td >
                    <input  name="ZDYongHu" value="" />
                </td>
                <td>营业经理:</td>
                <td >
                    <input  name="YingYeJingLi" value="" />
                </td>

            </tr>

            <tr>
                <td>
                    销售时间：
                </td>
                <td Colspan="3">                    
                    从<input name="XiaoShouShiJianFrom" class="easyui-datebox" type="text" value="" />
                    到<input name="XiaoShouShiJianTo" type="text" class="easyui-datebox" value="" />
                </td>
            </tr>
            
        </table>
        <div id="search-buttons">
            <a id="btn_search" href="javascript:;" class="easyui-linkbutton" iconcls="icon-search" plain="true">提交</a> 
            <a href="javascript:;" class="easyui-linkbutton" onclick="$('#tab_search').dialog('close');return false;" iconcls="icon-cancel" plain="true">取消</a>
        </div>
    </div>

    <div id="tab_toolbar" style="padding:2px;">
       <a href="#" title="高级查找" class="easyui-linkbutton" iconcls="icon-search" plain="true" onclick="$('#tab_search').dialog('open');" Permission="">查找</a>
      
       <a href="#"  class="easyui-linkbutton" iconcls="icon-btnDown" plain="true" onclick="return onExportList();" Permission="r导出" style="">导出</a>

    </div>   

   <table id="tab_list"  iconCls="" singleSelect="true" idField="FTradeID"  nowrap="false" striped="true" collapsible="false" remoteSort="true"  toolbar="#tab_toolbar"  pagination="true" pageNumber="1" pageSize="<%=numPerPage %>"  pageList="<%=SetnumPerPage() %>" rownumbers="true" showFooter="false" url="">
		<thead>
			<tr>
				<th field="HeTongHao" width="120" sortable="true">合同号</th>
				<th field="XiaoShouShiJian" width="80" sortable="true" formatter="formatterdate">销售时间</th>
				<th field="YingYeJingLi" width="80"  sortable="true">营业经理</th>
				<th field="JingXiaoShang" width="80" sortable="true">经销商</th>
				<th field="JiHao" width="80" sortable="true">机号</th>
				<%--<th field="Status" width="80" align="center" editor="{type:'checkbox',options:{on:'已发',off:'未发'}}" sortable="true">机器状态</th>--%>
                <th field="JiQiState"  width="80" >机器状态</th>
                <th field="ShuLiang" width="50" sortable="true">数量</th>
                <th field="HeTongYuanJian" width="80" align="center" editor="{type:'combobox',options:{valueField:'name',textField:'name',data:YuanJianLists}}" sortable="true">合同原件</th>
                 <th field="HeTongYuanJianDate" width="80" align="center" editor="{type:'datebox'}" sortable="true">接收时间</th>
                <th field="ShouHouYuanJian" width="80" align="center" editor="{type:'combobox',options:{valueField:'name',textField:'name',data:YuanJianLists}}" sortable="true">收货凭证原件</th>
                <th field="ShouHouYuanJianDate" width="80" align="center" editor="datebox" formatter="formatterdate" sortable="true">接收时间</th>
			</tr>
		</thead>
	</table>
</body>
</html>